<template>
  <div class="card" :class="{ 'card-hoverable': hoverable, 'card-bordered': bordered }">
    <div v-if="showHeader" class="card-header">
      <div class="card-title">
        <slot name="title">{{ title }}</slot>
      </div>
      <div v-if="$slots.extra" class="card-extra">
        <slot name="extra"></slot>
      </div>
    </div>
    <div class="card-body" :style="{ padding: bodyPadding }">
      <slot></slot>
    </div>
    <div v-if="$slots.footer" class="card-footer">
      <slot name="footer"></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Card',
  props: {
    title: {
      type: String,
      default: ''
    },
    bordered: {
      type: Boolean,
      default: true
    },
    hoverable: {
      type: Boolean,
      default: false
    },
    bodyPadding: {
      type: String,
      default: '16px'
    }
  },
  computed: {
    showHeader() {
      return this.title || this.$slots.title || this.$slots.extra
    }
  }
}
</script>

<style scoped>
.card {
  background-color: #fff;
  border-radius: 4px;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.card-bordered {
  border: 1px solid #f0f0f0;
}

.card-hoverable:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.09);
  border-color: rgba(0, 0, 0, 0.09);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #f0f0f0;
}

.card-title {
  font-size: 16px;
  color: rgba(0, 0, 0, 0.85);
  font-weight: 500;
}

.card-extra {
  color: rgba(0, 0, 0, 0.45);
}

.card-footer {
  padding: 16px;
  border-top: 1px solid #f0f0f0;
  color: rgba(0, 0, 0, 0.45);
}
</style> 